package com.chixing.controller;

import com.chixing.entity.Myorder;
import com.chixing.service.IMyorderService;
import com.chixing.service.impl.MyorderServiceImpl;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-21
 */
@RestController
@RequestMapping("/order")
public class MyorderController {
    @Autowired
    private IMyorderService myorderService;

    @GetMapping("{myorderId}")
    public Result getById(@PathVariable("myorderId") Integer myorderId) {
        return myorderService.getById(myorderId);
    }
    @GetMapping("/cust/{custId}")
    public Result getcustId(@PathVariable("custId") Integer custId) {
        return myorderService.getcustId(custId);
    }
    public MyorderController(IMyorderService myorderService) {
        this.myorderService = myorderService;
    }
    @PostMapping
    public Result save(@RequestBody Myorder myorder) {
        myorder.setCustId(1);
        return myorderService.save(myorder);
    }
}